package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.Permission_managementDao;
import com.itheima.dao.Role_managementDao;
import com.itheima.domain.Menu_management;
import com.itheima.domain.PageResult;
import com.itheima.domain.Permission_management;

import com.itheima.domain.Role_management;
import com.itheima.service.RoleService;
import com.itheima.service.Role_managementService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class Role_managementImpl implements Role_managementService {

    @Autowired
    private Role_managementDao roleDao;

    @Override
    public List<Role_management> findAll() {
        return roleDao.findAll();
    }

    @Override
    public Role_management findById(Integer userId) {
        return roleDao.findById(userId);
    }

    @Override
    public void updateRole(Role_management role) {
        roleDao.updateRole(role);
    }

    @Override
    public void save(Role_management role) {
     roleDao.save(role);
    }

    @Override
    //删除

    public void delete(Integer id) throws RuntimeException{
        //查询当前检查项是否和检查组关联

        roleDao.deleteById(id);
    }

    @Override
    public void edit(Role_management role_management) {
        roleDao.edit(role_management);

}

    public PageResult pageQuery(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<Role_management> page = roleDao.selectByCondition(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public List<Role_management> EstimateFindAll() {
        return roleDao.EstimateFindAll();
    }


}
